<?php
require_once '../../a_config.php';
require_once "{$A_CONFIG['api_include']}";
require_once '../../api_header.php';
$conn = connect_to_db();
$msg = "";
if (isset($_POST['token']) && !empty($_POST["token"]) &&
    isset($_POST['time']) && !empty($_POST["time"])) {
    $key = $A_CONFIG['api_key'];
    $unixtime = $_POST['time'];
    $token = md5($key . $unixtime);
    if ($token == $_POST["token"]) {
        $s_db_name = $A_CONFIG['project_pre'] . '_backstage_admin_list';
        $login_username = $_POST['login_username'];
        $sql = "SELECT * FROM {$s_db_name} where username = '$login_username'";
        $res = mysql_query($sql, $conn);
        if (is_resource($res)) {
            $info = array();
            while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
                $item = array();
                $item = $row;
                $info[] = $item;
            }
            $err = 0;
            $msg = $info;
        } else {
            $msg = "数据处理出错";
        }
    } else {
        $msg = "用户网点获取失败，请刷新页面";
    }

} else {
    $err = -5;
    $msg = "参数错误";
}
$resArr = compact("err", "msg");
$resJson = json_encode_cn($resArr);
echo $resJson;